import { defineConfig } from "vite";
import { resolve } from 'path'
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from "unplugin-auto-import/vite";
import UnoCSS from 'unocss/vite'
import Components from '@uni-helper/vite-plugin-uni-components'
import { NutResolver } from 'nutui-uniapp'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    UnoCSS(),
    AutoImport({
      imports: ["vue", "pinia"],   // 自动引入ref,toRef等插件
      dts: "src/types/auto-import-vue.d.ts",
    }),
    Components({
      resolvers: [NutResolver()],
    }),
    uni(),
  ],

  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@import \'@/styles/custom_theme.scss\';@import \'nutui-uniapp/styles/variables.scss\';',
      },
    },
  },

  // 配置别名
  resolve: {
    alias: {
      '@/': `/${resolve(__dirname, 'src')}/`,
    },
    // 扩展名
    extensions: [".js", ".ts", ".jsx", ".tsx", ".json", ".vue", ".mjs"],
  },
});
